﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Student/Student.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="LOGISTCBUS.Entities" %>
<%@ Import Namespace="LOGISTCBUS.Entities.Enums" %>
<%@ Import Namespace="LOGISTCBUS.DAO" %>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript" src="<%= Url.Content("~/Scripts/App/studentEdit.js") %>"></script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <strong>CADASTRO DE ALUNO</strong>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%
        var s = this.ViewData["student"] != null ? (Student)this.ViewData["student"] : new Student();
    %>
    <div class="box">
        <div class="tabs">
            <ul>
                <li class="titleBox" style="padding: 3px 0 6px 10px;">Preencha os campos abaixo:</li>
            </ul>
            <div style="padding: 20px;" align="center">
                <div class="box" style="width: 500px;">
                    <div class="tabs">
                        <div style="padding: 10px;">
                            <input type="hidden" id="hdfIdStudent" value="<%= s.Id %>" />
                            <table border="0" align="center" cellpadding="0" cellspacing="5" class="texto10azulclaro">
                                <tr>
                                    <td colspan="3" align="center">
                                        <p style='color: red; font-weight: bold;' id="lblMessage">
                                            <%= ViewData["error"] %>
                                        </p>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Nome:
                                    </td>
                                    <td>
                                        <input type="text" name="txtName" id="txtName" class="fForm required" maxlength="100"
                                            style="width: 200px;" tabindex="1" value="<%= s.Name %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        RG:
                                    </td>
                                    <td>
                                        <input type="text" name="txtRG" id="txtRG" class="fForm" style="width: 200px;" tabindex="2"
                                            value="<%= s.RG %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        CPF:
                                    </td>
                                    <td>
                                        <input type="text" name="txtCPF" id="txtCPF" class="fForm cpffield required" style="width: 200px;"
                                            tabindex="3" value="<%= s.CPF %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Data de Nascimento:
                                    </td>
                                    <td>
                                        <input type="text" name="txtBirthdate" id="txtBirthdate" class="fForm datefield"
                                            maxlength="10" style="width: 200px;" tabindex="4" value="<%= s.BirthDate != null ? Convert.ToDateTime(s.BirthDate).ToString("dd/MM/yyyy") : string.Empty %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Endereço:
                                    </td>
                                    <td>
                                        <input type="text" name="txtAddress" id="txtAddress" class="fForm" maxlength="200"
                                            style="width: 200px;" tabindex="5" value="<%= s.Address %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Estado:
                                    </td>
                                    <td>
                                        <select id="cboState" name="cboState" class="fForm" style="width: 201px;" tabindex="6">
                                            <option value="">--Selecione--</option>
                                            <%
                                                var city = s != null && s.City != null ? new CityDAO().selectById(s.City.Id) : new City();
                                                foreach (var st in new StateDAO().select())
                                                {
                                                    if (!String.IsNullOrEmpty(st.Name))
                                                    {
                                                        var selected = "";
                                                        if (city != null && city.Id > 0)
                                                        {
                                                            if (city.State.Id == st.Id)
                                                                selected = " selected ";
                                                        }
                                            %>
                                            <option <%= selected %> value="<%= st.Id %>">
                                                <%= st.Name %>
                                            </option>
                                            <%      }
                                                }
                                            %>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Cidade:
                                    </td>
                                    <td>
                                        <select id="cboCity" name="cboCity" class="fForm" style="width: 201px;" tabindex="7">
                                            <option value="">--Selecione--</option>
                                            <%
                                                if (s != null && s.Id > 0 && city != null && city.Id > 0)
                                                {
                                                    foreach (var ct in new CityDAO().selectByState(city.State.Id))
                                                    {
                                                        if (!String.IsNullOrEmpty(ct.Name))
                                                        {
                                                            var selected = "";
                                                            if (s != null && city != null)
                                                                if (city.Id == ct.Id)
                                                                    selected = " selected ";
                                            %>
                                            <option <%= selected %> value="<%= ct.Id %>">
                                                <%= ct.Name%>
                                            </option>
                                            <%          }
                                                    }
                                                }
                                            %>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Telefone:
                                    </td>
                                    <td>
                                        <input type="text" name="txtPhone" id="txtPhone" class="fForm" maxlength="20" style="width: 200px;"
                                            tabindex="8" value="<%= s.Phone %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Celular:
                                    </td>
                                    <td>
                                        <input type="text" name="txtCellular" id="txtCellular" class="fForm" maxlength="20"
                                            style="width: 200px;" tabindex="9" value="<%= s.Cellular %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Sexo:
                                    </td>
                                    <td>
                                        <select id="cboSex" name="cboSex" class="fForm" style="width: 201px;" tabindex="10">
                                            <option value="">--Selecione--</option>
                                            <%
                                                foreach (ESex e in Enum.GetValues(typeof(ESex)))
                                                {
                                                    if (e != null)
                                                    {
                                                        var selected = "";
                                                        if (s != null && s.Sex != null)
                                                            if (s.Sex == e)
                                                                selected = " selected ";
                                            %>
                                            <option <%= selected %> value="<%= Convert.ToInt32(e) %>">
                                                <%= WebHelpers.GetEnumDescription(e) %>
                                            </option>
                                            <%      }
                                                }
                                            %>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right" valign="middle">
                                        Descrição:
                                    </td>
                                    <td>
                                        <textarea id="txtDescription" rows="3" cols="100" class="fForm" style="width: 200px;
                                            height: 100px;" maxlength="500" tabindex="11"><%= s.Description %></textarea>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
                <div style="padding-top: 10px;">
                    <input name="btnSave" id="btnSave" type="button" value="Inserir" class="ui-button ui-state-default ui-corner-all botaoS"
                        tabindex="12" />
                </div>
            </div>
        </div>
    </div>
    <div align="center" class="texto10azulclaro" style="padding-top: 15px;">
        © 2012 - Todos os direitos reservados.
    </div>
</asp:Content>
